package com.xcc.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.Queue;
import org.springframework.amqp.core.TopicExchange;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Description: TopicRabbitConfig
 * @Author: xiechuang
 * @Date: 2022/12/5
 */
@Configuration
public class TopicRabbitConfig {

    public final static String key1 = "topic.key1";
    public final static String key2 = "topic.key2";

    @Bean
    public Queue key1Queue() {
        return new Queue(TopicRabbitConfig.key1);
    }

    @Bean
    public Queue key2Queue() {
        return new Queue(TopicRabbitConfig.key2);
    }

    @Bean
    public TopicExchange exchange() {
        return new TopicExchange("topicExchange");
    }

    @Bean
    Binding bindingExchangeMessage1() {
        return BindingBuilder.bind(key1Queue()).to(exchange()).with(key1);
    }

    @Bean
    Binding bindingExchangeMessage2() {
        return BindingBuilder.bind(key2Queue()).to(exchange()).with(key2);
    }

}
